<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div class="box">盒子1</div>
    <div class="box">盒子2</div>
    <div id="nav">
        <ul>
            <li>首页</li>
            <li>产品</li>
        </ul>
    </div>
    <script>
        /* 
          1. getElementsByClassName 通过类名获取元素
          2. 返回的也是一个集合
          3. querySelector() 参数可以是类名，标签名，id。
              默认是标签名， #id,   .className
          4. querySelector() 返回的是第一元素 
          5. querySelectorAll() 返回元素的集合  
      */
        var boxs = document.getElementsByClassName("box");
        console.log(boxs);
        console.log('----------------');
        var li = document.querySelector("li");
        console.log(li);
        var div = document.querySelector("#nav");
        console.log(div);
        var box = document.querySelector(".box");
        console.log(box);
        console.log('----------------');
        var boxes = document.querySelectorAll(".box");
        console.log(boxes);
    </script>
</body>

</html>